﻿using OxyPlot;
using OxyPlot.Axes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OxyPlotChartingDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private MainViewModel _mainViewModel = null;
        public MainWindow()
        {
            InitializeComponent();
            lineSeriesPlot.ActualController.BindMouseEnter(PlotCommands.HoverTrack);
            lineSeriesPlot.ActualController.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            _mainViewModel = this.DataContext as MainViewModel;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _mainViewModel.FailurePoints = new List<DataPoint>
                              {
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,1)),TimeSpanAxis.ToDouble(new TimeSpan(0,0,15,15,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,2)),TimeSpanAxis.ToDouble(new TimeSpan(0,0,20,0,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,3)),TimeSpanAxis.ToDouble(new TimeSpan(0,2,22,56,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,4)),TimeSpanAxis.ToDouble(new TimeSpan(1,23,56,25,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,5)),TimeSpanAxis.ToDouble(new TimeSpan(0,6,10,15,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,6)),TimeSpanAxis.ToDouble(new TimeSpan(0,12,0,0,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,7)),TimeSpanAxis.ToDouble(new TimeSpan(2,2,15,0,0))),
                              };

            _mainViewModel.SuccessPoints = new List<DataPoint>
                              {
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,1)),TimeSpanAxis.ToDouble(new TimeSpan(0,0,10,15,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,2)),TimeSpanAxis.ToDouble(new TimeSpan(0,1,15,15,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,3)),TimeSpanAxis.ToDouble(new TimeSpan(3,23,22,56,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,4)),TimeSpanAxis.ToDouble(new TimeSpan(5,23,56,25,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,5)),TimeSpanAxis.ToDouble(new TimeSpan(0,15,20,15,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,6)),TimeSpanAxis.ToDouble(new TimeSpan(2,0,0,0,0))),
                                  new DataPoint(DateTimeAxis.ToDouble(new DateTime(2015,1,7)),TimeSpanAxis.ToDouble(new TimeSpan(1,2,15,0,0))),
                              };
        }
    }
}